/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.shop.utils;

import java.util.List;

import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import com.thinkgem.jeesite.modules.shop.dao.AttributeItemDao;
import com.thinkgem.jeesite.modules.shop.dao.ParameterItemDao;
import com.thinkgem.jeesite.modules.shop.dao.SpecificationItemDao;
import com.thinkgem.jeesite.modules.shop.entity.Attribute;
import com.thinkgem.jeesite.modules.shop.entity.AttributeItem;
import com.thinkgem.jeesite.modules.shop.entity.Goods;
import com.thinkgem.jeesite.modules.shop.entity.GoodsCategory;
import com.thinkgem.jeesite.modules.shop.entity.Navigation;
import com.thinkgem.jeesite.modules.shop.entity.Parameter;
import com.thinkgem.jeesite.modules.shop.entity.ParameterItem;
import com.thinkgem.jeesite.modules.shop.entity.Specification;
import com.thinkgem.jeesite.modules.shop.entity.SpecificationItem;
import com.thinkgem.jeesite.modules.shop.service.GoodsCategoryService;
import com.thinkgem.jeesite.modules.shop.service.GoodsService;
import com.thinkgem.jeesite.modules.shop.service.NavigationService;

/**
 * 网店模型工具类
 * @author xxs
 */
public class ShopUtils {
	
	private static ParameterItemDao parameterItemDao = SpringContextHolder.getBean(ParameterItemDao.class);
	private static AttributeItemDao attributeItemDao = SpringContextHolder.getBean(AttributeItemDao.class);
	private static SpecificationItemDao specificationItemDao = SpringContextHolder.getBean(SpecificationItemDao.class);
	private static NavigationService navigationService = SpringContextHolder.getBean(NavigationService.class);
	private static GoodsCategoryService goodsCategoryService = SpringContextHolder.getBean(GoodsCategoryService.class);
	private static GoodsService goodsService = SpringContextHolder.getBean(GoodsService.class);

	/**
	 * 获得参数列表
	 * @param 参数
	 */
	public static List<ParameterItem> getParameterItemList(Parameter parameter ){
		return parameterItemDao.findList(new ParameterItem(parameter));
	}
	/**
	 * 获得属性列表
	 * @param 属性
	 */
	public static List<AttributeItem> getAttributeItemList(Attribute attribute ){
		return attributeItemDao.findList(new AttributeItem(attribute));
	}
	/**
	 * 获得规格列表
	 * @param 规格
	 */
	public static List<SpecificationItem> getSpecificationItemList(Specification specification  ){
		return specificationItemDao.findList(new SpecificationItem(specification));
	}
	/**
	 * 获得导航列表
	 * @param 导航
	 */
	public static List<Navigation> getNavLists(String id){
		Navigation navigation = new Navigation();
		navigation.setDelFlag("1");
		return navigationService.findList(navigation);
	}
	/**
	 * 获得商品列表
	 * @param 导航
	 */
	public static List<Goods> getGoodsLists(String goodsCategoryId){
		Goods goods = new Goods();
		goods.setDelFlag("1");
		goods.setGoodsCategory(new GoodsCategory(goodsCategoryId));
		return goodsService.findList(goods);
	}
	
	/**
	 * 获取商品分类列表
	 * @param categoryIds 商品分类编号
	 * @return
	 */
	public static List<GoodsCategory> getGoodsCategoryListByIds(String categoryIds){
		return goodsCategoryService.findByIds(categoryIds);
	}
	/**
	 * 获取商品分类列表tree
	 * @return
	 */
	public static List<GoodsCategory> getGoodsCategoryListByParentId(String parentId){
		return goodsCategoryService.getGoodsCategoryListByParentId(parentId);
	}
}